<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>上下滑动登录/注册切换</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      }

      body {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        padding: 20px;
      }

      .container {
        background: rgba(255, 255, 255, 0.95);
        border-radius: 30px;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
        width: 100%;
        max-width: 450px;
        overflow: hidden;
        position: relative;
        height: 550px;
      }

      .toggle-container {
        position: relative;
        height: 80px;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding-top: 20px;
      }

      .toggle-btn {
        position: absolute;
        top: 60px;
        left: 50%;
        width: 120px;
        height: 4px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 2px;
        transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
        transform: translateX(-50%);
      }

      .toggle-btn.slide-down {
        top: 120px;
      }

      .toggle-labels {
        position: relative;
        display: flex;
        gap: 40px;
        z-index: 2;
        flex-direction: column;
        align-items: center;
      }

      .toggle-label {
        padding: 10px 20px;
        cursor: pointer;
        color: #666;
        font-weight: 600;
        transition: color 0.3s;
        font-size: 18px;
      }

      .toggle-label.active {
        color: #667eea;
      }

      .form-container {
        position: relative;
        height: calc(100% - 100px);
        margin-top: 20px;
      }

      .form {
        position: absolute;
        width: 100%;
        padding: 0 30px;
        opacity: 0;
        transform: translateY(-20px);
        transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
        pointer-events: none;
      }

      .form.active {
        opacity: 1;
        transform: translateY(0);
        position: relative;
        pointer-events: auto;
      }

      .form-group {
        margin-bottom: 25px;
        position: relative;
      }

      .form-input {
        width: 100%;
        padding: 12px 15px;
        border: 2px solid #e0e0e0;
        border-radius: 25px;
        font-size: 16px;
        transition: all 0.3s ease;
      }

      .form-input:focus {
        outline: none;
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
      }

      .form-button {
        width: 100%;
        padding: 12px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 25px;
        cursor: pointer;
        font-size: 16px;
        font-weight: 600;
        transition: transform 0.2s;
        margin-top: 10px;
      }

      .form-button:hover {
        transform: translateY(-2px);
      }

      .form-button:active {
        transform: translateY(0);
      }

      .social-login {
        margin-top: 20px;
        text-align: center;
      }

      .social-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 20px;
        margin: 5px;
        border-radius: 25px;
        border: none;
        cursor: pointer;
        transition: all 0.3s;
      }

      .google-btn {
        background: #fff;
        color: #4285f4;
        border: 1px solid #ddd;
      }

      .google-btn:hover {
        background: #4285f4;
        color: white;
      }

      .facebook-btn {
        background: #3b5998;
        color: white;
      }

      .facebook-btn:hover {
        background: #2d4373;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="toggle-container">
        <div class="toggle-btn"></div>
        <div class="toggle-labels">
          <label class="toggle-label active" onclick="toggleForm('login')">登录</label>
          <label class="toggle-label" onclick="toggleForm('register')">注册</label>
        </div>
      </div>

      <div class="form-container">
        <!-- 登录表单 -->
        <form class="form active" id="loginForm">
          <div class="form-group">
            <input type="text" class="form-input" placeholder="用户名/邮箱" />
          </div>
          <div class="form-group">
            <input type="password" class="form-input" placeholder="密码" />
          </div>
          <button type="submit" class="form-button">立即登录</button>
          <div class="social-login">
            <button class="social-btn google-btn">
              <img src="https://img.icons8.com/color/24/000000/google-logo.png" alt="Google" />
              Google
            </button>
            <button class="social-btn facebook-btn">
              <img src="https://img.icons8.com/color/24/000000/facebook-new.png" alt="Facebook" />
              Facebook
            </button>
          </div>
        </form>

        <!-- 注册表单 -->
        <form class="form" id="registerForm">
          <div class="form-group">
            <input type="text" class="form-input" placeholder="用户名" />
          </div>
          <div class="form-group">
            <input type="email" class="form-input" placeholder="电子邮箱" />
          </div>
          <div class="form-group">
            <input type="password" class="form-input" placeholder="密码" />
          </div>
          <button type="submit" class="form-button">注册账号</button>
        </form>
      </div>
    </div>

    <script>
      function toggleForm(formType) {
        const container = document.querySelector('.container')
        const toggleBtn = document.querySelector('.toggle-btn')
        const forms = document.querySelectorAll('.form')
        const labels = document.querySelectorAll('.toggle-label')

        // 切换标签激活状态
        labels.forEach((label) => label.classList.remove('active'))
        event.target.classList.add('active')

        // 切换表单显示
        forms.forEach((form) => {
          form.classList.remove('active')
          if (form.id === `${formType}Form`) {
            form.classList.add('active')
          }
        })

        // 切换按钮动画
        toggleBtn.classList.toggle('slide-down', formType === 'register')
      }
    </script>
  </body>
</html>
